$(function () {
    var form = layui.form
    var layer = layui.layer

    form.verify({
        pwd: [/^[\S]{6,12}$/, '密码必须6到12位，且不能出现空格'],
        repwd: function (value) {
            var pwd = $('.row [name=regist_pwd]').val()
            if (pwd !== value) {
                return '两次密码不一样'
            }
        }
    })

    $('#form_reg').on('submit', function (e) {
        e.preventDefault()
        var data = {
            username: $('#form_reg [regist_account]').val(),
            password: $('#form_reg [regist_pwd]').val()
        }
        $.ajax({
            type: "POST",
            url: "http://192.168.23.30:3000/user",
            data: data,
            success: function () {
                location.href = '../login.html'
            }
        });
    })
})